package com.four.controller;


import com.four.entity.Role;
import com.four.service.RoleService;
import com.four.vo.Result;
import com.four.vo.RoleVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: qy158-system
 * @description:
 * @author: 闫克起2
 * @create: 2022-10-11 10:32
 **/
@RestController
@RequestMapping("role")
public class RoleController {
    @Autowired
    private RoleService roleService;

    @GetMapping("/list")
    public Result list(Integer adminId){
        return roleService.findByUserId(adminId);
    }

    @PostMapping("qr")
    public Result qr(Integer roleId,Integer[] pIds){

        return  roleService.qr(roleId,pIds);
    }

    @PostMapping("/all")
    public Result all(@RequestParam(defaultValue = "1")Integer currentPage,
                      @RequestParam(defaultValue = "5")Integer pageSize){
        return roleService.findByCondition(currentPage,pageSize);
    }
    @PostMapping("/updata")
    public Result updata(@RequestBody Role role){
       return roleService.updata(role);
    }
    @GetMapping("delete")
    public Result delete(Integer roleId){return roleService.delete(roleId);}

    @PostMapping("add")
    public Result add(@RequestBody Role role){
        return roleService.addRole(role);
    }
}
